﻿cmake_minimum_required(VERSION 3.24)

set(NCTI_PROJECT ${NCTI_QT_PUBFUN})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_compile_definitions (EXPORT_NCTI_QT_PUBFUN)

# Qt自动处理
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC OFF)

# 查找Qt库
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network Svg REQUIRED)

# 不使用Qt关键字
add_compile_definitions(QT_NO_KEYWORDS)

# 指定禁用 Qt 6.0.0 之前的已弃用 API
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060000)

if(ENABLE_SHOW_SCENE_VIEW)
  add_compile_definitions(NCTI_SHOW_SCENE_VIEW)
endif()

# 包含目录
include_directories(${INC_PATH_NCTI})
include_directories(${INC_PATH_PYTHON})

FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_BASE})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_RENDER})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_PLUGINMANAGER})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_GEOM_ENGINE})

FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_WINDOW})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_PLUGIN})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_OBJECT})
FUN_FIND_ALL_HEADFILE_DIR(${NCTI_APPLICATION_DIR_NCTICAX_INC} ${NCTI_PUBFUN})

FUN_FIND_ALL_HEADFILE_DIR(${CMAKE_CURRENT_SOURCE_DIR}/../../Inc ${NCTI_QT_SCRIPT_EDIT})

# 生成目标
NCTI_CODE_BUILD()

# 添加库目录
target_link_directories(${NCTI_PROJECT} PRIVATE
  ${LIB_PATH_NCTI}
  ${LIB_PATH_PYTHON}
)

# 添加第三方头文件目录
target_include_directories(${NCTI_PROJECT} PRIVATE 
  ${NCTI_3RDPARTY_INC}
  ${NCTI_3RDPARTY_INC}/QtPropertyBrowser
)

# 添加第三方库目录
target_link_directories(${NCTI_PROJECT} PRIVATE
	${NCTI_3RDPARTY_LIB}
    ${NCTI_3RDPARTY_LIB}/Windows/RelWithDebInfo/qBreakpad
)

# 添加 Unicode 字符集支持
target_compile_definitions(${NCTI_PROJECT} PRIVATE UNICODE _UNICODE)

target_link_libraries(${NCTI_PROJECT} PRIVATE
  Qt${QT_VERSION_MAJOR}::Core
  Qt${QT_VERSION_MAJOR}::Gui
  Qt${QT_VERSION_MAJOR}::Widgets
  Qt${QT_VERSION_MAJOR}::Network
  Qt${QT_VERSION_MAJOR}::Svg
)

# 链接NCTI库
target_link_libraries(${NCTI_PROJECT} PRIVATE
  ${NCTI}
  ${NCTI_BASE}
  ${NCTI_RENDER}
  ${NCTI_WINDOW}
  ${NCTI_PLUGINMANAGER}
  ${NCTI_PLUGIN}
  ${NCTI_PUBFUN}
  ${NCTI_OBJECT}
  ${NCTI_GEOM_ENGINE}
)

target_link_libraries(${NCTI_PROJECT} PRIVATE
  ${NCTI_QT_SCRIPT_EDIT}
  QtPropertyBrowser
)